<%@ page import="com.scalar.chiptrack.utils.ConfigManager"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>

<chiptrack:checkLogon sourcePage="/cummulativeYieldReport.do" />

<%String chipTracContext = "/" + ConfigManager.getChipTracContext(); %>

<HTML><HEAD><TITLE>Scalarsoft - ChipTrac</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type="text/css" rel=stylesheet>
<SCRIPT language="JavaScript" src="<%=chipTracContext%>/jsp/includes/scripts/functions.js"></SCRIPT>
<SCRIPT language="JavaScript" src="<%=chipTracContext%>/jsp/includes/scripts/validations.js"></SCRIPT>

<SCRIPT language="JavaScript">
function ExportToExcel()
{
    var form = document.cumYieldReportForm;

    var productId  = form.productId.value;
    
    var url = '<%=chipTracContext%>/operationsDataDumpReports.do?action=cumyieldReport&popUp=true&baseProductId=' + productId;

    newWindow = window.open ( url, 'CummYieldReport', 'channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=yes,width=450,height=150,resizable=yes');

}

function attachFile()
{
    var form        = document.cummulativeYieldForm;
    var errors      = "";
    var fileCtrl    = form.attachmentFile;

    if( form.baseProductId.value == -1 )
    {
        errors =  errors + "<li>Please select Base Product Name</li>"
    }
    else if ( fileCtrl.value.trim() == "" )
	{
      	errors =  errors + "<li>Please select a file to attach</li>"
        window.scrollTo(0,0);
    }
	var fileValue   = fileCtrl.value;
	fileValue       = fileValue.replace ( '/', '\\' );
	var position    = fileValue.lastIndexOf( '\\' );
	var poFileName  = fileValue.substr( ( position + 1 ) , fileValue.length );

	if( fileValue.indexOf( "'" ) >= 0 || fileValue.indexOf( "%" ) >= 0 )
	{
		errors =  errors + "<li>' + ' File name should not contain ' % characters";
	}

    if( errors != "" )
    {
        var pa = document.getElementById("errors");
        pa.innerHTML = errors;
        return;
    }
    else
    {
        document.cummulativeYieldForm.action = '<%=chipTracContext%>/cummulativeYieldReport.do?action=upload';
        document.cummulativeYieldForm.submit();
    }
}

function process( baseProductId )
{
    var form    = document.cummulativeYieldForm;
    var errors  = "";

    if( errors != "" )
    {
        var pa = document.getElementById("errors");
        pa.innerHTML = errors;
        return;
    }
    else
    {
        document.cummulativeYieldForm.action = '<%=chipTracContext%>/cummulativeYieldReport.do?action=process&baseProductId=' + baseProductId;
        document.cummulativeYieldForm.submit();
    }
}

</script>
</HEAD>
<BODY bgColor="#ffffff" leftMargin=0 topMargin=0 marginheight="0" marginwidth="0">
<!-- Top Header Start-->
<%@ include file="/jsp/includes/header.jsp" %>
<!-- Top Header End-->
<table cellSpacing=0 cellPadding=0 width="100%" border="0">
    <tr>
        <td width='180' valign='top' background='<%=chipTracContext%>/jsp/includes/images/left_red_bg.gif'>
            <!-- Side Navigation start -->
            <%@ include file="/jsp/engineering/engg_report_menu.jsp" %>
            <!-- end of the side navigations -->
        </td>
        <td bgcolor="#ffffff"><img height=9 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=8></td>
        <td bgcolor="#ffffff"><img height=480 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=2></td>
        <html:form name="cummulativeYieldForm" action="/cummulativeYieldReport" enctype="multipart/form-data" type="com.scalar.chiptrack.engineering.forms.CummulativeYieldForm">
        <td valign="top" width="100%">
            <table border="0" width="100%" align="center">
                <tr><td colspan="6" width="100%"><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td></tr>
                <tr><td colspan="6" width="100%"><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td></tr>
                <tr><td colspan="6" width="100%"><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td></tr>
                <tr>
                    <td width="100%" COLSPAN="6">
                        <table width="100%" align=right border="0">
                            <tr>
                                <td width="20%">&nbsp;</td>
                                <td width="60%" class="NArialW" align="center">Cumm Yield Report</td>
                                <td width="20%">&nbsp;</td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr><td colspan="6" width="100%"><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td></tr>
                <tr>
                    <td width="10%">&nbsp;</td>
                    <td width="90%" colspan="5" align="left">
                        <chiptrack:errors styleClass="NArialL"/>
                        <br>
                        <chiptrack:info styleClass="NArialL"/>
                    </td>
                </tr>
                <tr>
                    <td>&nbsp;</td>
                    <td colspan="5" align="left">
                        <b><font face="Verdana" size="-5" align="center" color="#ff0000" id="errors"></font></b>&nbsp;
                    </td>
                </tr>
                <tr>
                    <td width="2%">&nbsp;</td>
                    <td width="15%" align="left" class=NArialL>Base Product Name:</td>
                    <td width="20%" class=NArialL>
                        <html:select property="baseProductId"  styleClass="txfield" style="width:180px">
                            <html:option value="-1">--Select Product--</html:option>
                            <html:options collection="baseProductList" property="value" labelProperty="label"/>
                        </html:select>
                    </td>
                    <td colspan="3">&nbsp;</td>
                </tr>
                <tr>
                    <td>&nbsp;</td>
                    <td align="left" class=NArialL>Upload File:</td>
                    <td colspan="4" class="NArialL">
                        <html:file property="attachmentFile" size="83" styleClass="txfield"/>
                        <a href="javascript:attachFile()" onMouseOver="window.status='Click to Attach a File';return true"onmouseout="window.status='';return true"><b>Attach</b></a>
                    </td>
                </tr>
                <tr><td colspan="6" width="100%"><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td></tr>
                <tr><td colspan="6" width="100%"><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td></tr>
                <tr>
                    <td>&nbsp;</td>
                    <td colspan="5">
                        <table border="0" width="80%">
                                <tr bgcolor="#993333" height="28">
                                    <td width="20%" align="center" class="NArialL"><font color="#FFFFFF">Base Product Name</font></td>
                                    <td width="40%" align="center" class="NArialL"><font color="#FFFFFF">File Name</font></td>
                                    <td width="18%" align="center" class="NArialL"><font color="#FFFFFF">Upload Time</font></td>
                                    <td width="18%" align="center" class="NArialL"><font color="#FFFFFF">Last Updated Time</font></td>
                                    <td width="12%" align="center" class="NArialL"><font color="#FFFFFF">Action</font></td>
                                </tr>
                                <logic:iterate name="cummulativeYieldForm" property="cummulativeFileInfoList" id="cummulativeYieldInfo" type="com.scalar.chiptrack.engineering.CummulativeYieldInfo" indexId="iteratorIdx">
                                <tr <%if(iteratorIdx.intValue()%2==0){%> bgcolor='#DEE1E2' <% } else {%> bgcolor='#FFFFEE' <%}%>  height="20">
                                    <td class="NArialL" align="center">
                                        <bean:write name="cummulativeYieldInfo" property="baseProductName" />
                                    </td>
                                    <td class="NArialL" align="center">
                                        <a href="<bean:write name="cummulativeYieldInfo" property="attachFile.fileWebPathEncoded"/>" target="_newWindow" onMouseOver="window.status='Please right-click & choose Save target as';return true"onmouseout="window.status='';return true" title="Please right-click & choose Save target as"><bean:write name="cummulativeYieldInfo" property="attachFile.fileName"/></a>
                                        <html:hidden name="cummulativeYieldInfo" property="attachFile.fileName"/>
                                        &nbsp;
                                    </td>
                                    <td  class="NArialL" align="center" >
                                        <bean:write name="cummulativeYieldInfo" property="uploadDateTime" filter="false" />
                                    </td>
                                    <td  class="NArialL" align="center" >
                                        <bean:write name="cummulativeYieldInfo" property="lastUpdatedDateTime" />
                                    </td>
                                    <td  class="NArialL" align="center">
                                        <logic:notPresent name="cummulativeYieldInfo" property="attachFile.fileName">
                                            <b>Process</b>
                                        </logic:notPresent>
                                        <logic:present name="cummulativeYieldInfo" property="attachFile.fileName">
                                            <a href="javascript:process('<bean:write name="cummulativeYieldInfo" property="baseProductId"/>')" onMouseOver="window.status='Click to Process';return true"onmouseout="window.status='';return true"><b>Process</b></a>
                                        </logic:present>
                                    </td>
                                </tr>
                                </logic:iterate>
                        </table>
                    </td>
                </tr>                
                <tr><td colspan="6" width="100%"><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td></tr>
                <tr><td colspan="6"><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20>&nbsp;</td></tr>
                <%--<tr>
                    <td colspan="6" align=center>
                        <a href="javascript:ExportToExcel();"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/submit.gif" width="53" height="17" onmouseover="window.status='Click to Generate Cumm Yield Report';return true" onmouseout="window.status='';return true" title="Click here to Generate Cumm Yield Report"></a>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        <a href="javascript:document.cumYieldReportForm.reset();"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/reset.gif" width="53" height="17" onmouseover="window.status='Click to reset ';return true" onmouseout="window.status='';return true" title="Click here to reset"></a>
                    </td>
                </tr>--%>
            </table>
            </html:form>
            <br><br><br>
            <br><br><br>
            <br><br>
        </td>
        <td bgcolor="#ffffff"><img height=1 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=1></td>
    </tr>
</table>
<!-- Footer starts here -->
<%@ include file="/jsp/includes/footer.jsp" %>
<!-- footer end here -->
</BODY>
</HTML>